All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JCheckBoxMenuItem

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.AbstractButton
                                   |
                                   +----com.sun.java.swing.JMenuItem
                                           |
                                           +----com.sun.java.swing.JCheckBoxMenuItem

public class JCheckBoxMenuItem
extends JMenuItem
implements SwingConstants, Accessible
A menu item that can be selected or deselected. If selected, the menu item typically appears with a checkmark next to it. If unselected or deselected, the menu item appears without a checkmark. Like a regular menu item, a checkbox menu item can have either text or a graphic icon associated with it, or both.

Either isSelected/setSelected or getState/setState can be used to determine/specify the menu item's selection state. (The Swing-standard methods are isSelected and setSelected. These methods work for all menus and buttons. The getState and setState methods exist for compatibility with other component sets.)

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JCheckBoxMenuItem key assignments.

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Constructor Index

 o JCheckBoxMenuItem()
Creates an initially unselected checkboxMenuItem with no set text or icon.
 o JCheckBoxMenuItem(Icon)
Creates an initially unselected checkboxMenuItem with an icon.
 o JCheckBoxMenuItem(String)
Creates an initially unselected checkboxMenuItem with text.
 o JCheckBoxMenuItem(String, boolean)
Creates a checkboxMenuItem with the specified text and selection state.
 o JCheckBoxMenuItem(String, Icon)
Creates an initially unselected checkboxMenuItem with the specified text and icon.
 o JCheckBoxMenuItem(String, Icon, boolean)
Creates a checkboxMenuItem with the specified text, icon, and selection state.

Method Index

 o getAccessibleContext()
Get the AccessibleContext associated with this JComponent
 o getSelectedObjects()
Returns an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.
 o getState()
Returns the selected-state of the item.
 o getUIClassID()
Returns the name of the L&F class that renders this component.
 o init(String, Icon)
Initialize the menu item with the specified text and icon.
 o requestFocus()
Set focus on the receiving component if isRequestFocusEnabled returns true
 o setState(boolean)
Sets the selected-state of the item.
 o setUI(CheckBoxMenuItemUI)
Sets L&F object that renders this component.
 o updateUI()
Notification from the UIFactory that the L&F has changed.

Constructors

 o JCheckBoxMenuItem
 public JCheckBoxMenuItem()
Creates an initially unselected checkboxMenuItem with no set text or icon.

 o JCheckBoxMenuItem
 public JCheckBoxMenuItem(Icon icon)
Creates an initially unselected checkboxMenuItem with an icon.

Parameters:
icon - the icon of the CheckBoxMenuItem.
 o JCheckBoxMenuItem
 public JCheckBoxMenuItem(String text)
Creates an initially unselected checkboxMenuItem with text.

Parameters:
text - the text of the CheckBoxMenuItem
 o JCheckBoxMenuItem
 public JCheckBoxMenuItem(String text,
                          Icon icon)
Creates an initially unselected checkboxMenuItem with the specified text and icon.

Parameters:
text - the text of the CheckBoxMenuItem
icon - the icon of the CheckBoxMenuItem
 o JCheckBoxMenuItem
 public JCheckBoxMenuItem(String text,
                          boolean b)
Creates a checkboxMenuItem with the specified text and selection state.

Parameters:
text - the text of the CheckBoxMenuItem.
b - the selected state of the checkboxmenuitem
 o JCheckBoxMenuItem
 public JCheckBoxMenuItem(String text,
                          Icon icon,
                          boolean b)
Creates a checkboxMenuItem with the specified text, icon, and selection state.

Parameters:
text - the text of the CheckBoxMenuItem
icon - the icon of the CheckBoxMenuItem
b - the selected state of the checkboxmenuitem

Methods

 o init
 protected void init(String text,
                     Icon icon)
Initialize the menu item with the specified text and icon.

Overrides:
init in class JMenuItem
 o setUI
 public void setUI(CheckBoxMenuItemUI ui)
Sets L&F object that renders this component.

Parameters:
ui - the new L&F object CheckBoxMenuItemUI
See Also:
getUI
 o updateUI
 public void updateUI()
Notification from the UIFactory that the L&F has changed.

Overrides:
updateUI in class JMenuItem
See Also:
updateUI
 o getUIClassID
 public String getUIClassID()
Returns the name of the L&F class that renders this component.

Returns:
"CheckBoxMenuItemUI"
Overrides:
getUIClassID in class JMenuItem
See Also:
getUIClassID, getUI
 o getState
 public boolean getState()
Returns the selected-state of the item. This method exists for AWT compatibility only. New code should use isSelected() instead.

Returns:
true if the item is selected
 o setState
 public synchronized void setState(boolean b)
Sets the selected-state of the item. This method exists for AWT compatibility only. New code should use setSelected() instead.

Parameters:
b - a boolean value indicating the item's selected-state, where true=selected
 o getSelectedObjects
 public synchronized Object[] getSelectedObjects()
Returns an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.

Returns:
an array containing 1 Object -- the text of the menu item -- if the item is selected, otherwise null
Overrides:
getSelectedObjects in class AbstractButton
 o requestFocus
 public void requestFocus()
Set focus on the receiving component if isRequestFocusEnabled returns true

Overrides:
requestFocus in class JComponent
 o getAccessibleContext
 public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent

Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JMenuItem

All Packages  Class Hierarchy  This Package  Previous  Next  Index